package com.ruoyi.system.service.impl;

import java.util.ArrayList;
import java.util.List;

import com.ruoyi.system.domain.TeaShopWorkPlace;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.WarehouseDeliveryInformationMapper;
import com.ruoyi.system.domain.WarehouseDeliveryInformation;
import com.ruoyi.system.service.IWarehouseDeliveryInformationService;
import com.ruoyi.common.core.text.Convert;

/**
 * 发货信息Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-01-06
 */
@Service
public class WarehouseDeliveryInformationServiceImpl implements IWarehouseDeliveryInformationService 
{
    @Autowired
    private WarehouseDeliveryInformationMapper warehouseDeliveryInformationMapper;

    /**
     * 查询发货信息
     * 
     * @param id 发货信息主键
     * @return 发货信息
     */
    @Override
    public WarehouseDeliveryInformation selectWarehouseDeliveryInformationById(Long id)
    {
        return warehouseDeliveryInformationMapper.selectWarehouseDeliveryInformationById(id);
    }

    /**
     * 查询发货信息列表
     * 
     * @param warehouseDeliveryInformation 发货信息
     * @return 发货信息
     */
    @Override
    public List<WarehouseDeliveryInformation> selectWarehouseDeliveryInformationList(WarehouseDeliveryInformation warehouseDeliveryInformation)
    {
        return warehouseDeliveryInformationMapper.selectWarehouseDeliveryInformationList(warehouseDeliveryInformation);
    }

    /**
     * 新增发货信息
     * 
     * @param warehouseDeliveryInformation 发货信息
     * @return 结果
     */
    @Override
    public int insertWarehouseDeliveryInformation(WarehouseDeliveryInformation warehouseDeliveryInformation)
    {
        return warehouseDeliveryInformationMapper.insertWarehouseDeliveryInformation(warehouseDeliveryInformation);
    }

    /**
     * 修改发货信息
     * 
     * @param warehouseDeliveryInformation 发货信息
     * @return 结果
     */
    @Override
    public int updateWarehouseDeliveryInformation(WarehouseDeliveryInformation warehouseDeliveryInformation)
    {
        return warehouseDeliveryInformationMapper.updateWarehouseDeliveryInformation(warehouseDeliveryInformation);
    }

    /**
     * 批量删除发货信息
     * 
     * @param ids 需要删除的发货信息主键
     * @return 结果
     */
    @Override
    public int deleteWarehouseDeliveryInformationByIds(String ids)
    {
        return warehouseDeliveryInformationMapper.deleteWarehouseDeliveryInformationByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除发货信息信息
     * 
     * @param id 发货信息主键
     * @return 结果
     */
    @Override
    public int deleteWarehouseDeliveryInformationById(Long id)
    {
        return warehouseDeliveryInformationMapper.deleteWarehouseDeliveryInformationById(id);
    }

    @Override
    public int selectDeliveryInformation(String ids) {
        Long[] deliveryIds = Convert.toLongArray(ids);
        List<WarehouseDeliveryInformation> list = new ArrayList<WarehouseDeliveryInformation>();
        for (Long id : deliveryIds)
        {
            WarehouseDeliveryInformation temp = warehouseDeliveryInformationMapper.selectWarehouseDeliveryInformationById(id);
            temp.setInventoryId(warehouseDeliveryInformationMapper.selectAddInventory(temp));
            System.out.println(temp);
            list.add(temp);
            int b = warehouseDeliveryInformationMapper.updateAddInventory(temp);
        }
        return warehouseDeliveryInformationMapper.selectDeliveryInformation(list);
    }
}
